package com.jxut.qq;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

public class Demo extends JFrame {

    public static void main(String[] args) {
        Demo demo=new Demo();
        demo.intit();
        //JFrame window1=new JFrame();
        //window1.setBounds(100,100,300,100);
       // window1.setVisible(true);

    }
    private void intit(){
        //设置标题
        this.setTitle("标题");
        JLabel label=new JLabel("hello World");
        //将控件添加到窗体中
        this.add(label, BorderLayout.NORTH);
        //创建按钮
        JButton JButton=new JButton("按钮");
        //将按钮添加到窗口中
        this.add(JButton,BorderLayout.SOUTH);
        //创建图片控件
        URL url=this.getClass().getClassLoader().getResource("image/.png");
        //设置窗口的大小
        //JLabel label2=new JLabel(new ImageIcon(url));
        //this.add(label2,BorderLayout.EAST);

        this.setSize(600,600);
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        this.setLocationRelativeTo(null);
    }
}
